﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Animator))]
public class UI_Panel : MonoBehaviour
{
    private Animator animator;
    private bool isShow = false;
    void Awake()
    {
        animator = GetComponent<Animator>();
        EventManager.Add(EventNameConfig.UI.UnShow, unShow);

    }
    public void Show()
    {
        animator.SetBool("isShow", true);
        EventManager.Invoke(EventNameConfig.UI.UnShow,this);
        EventManager.Invoke(EventNameConfig.UI.BG_Show);
    }
    public void unShow(object[] o)
    {
        if (o==null)
        {
            animator.SetBool("isShow", false);
            return;
        }
        UI_Panel u = (UI_Panel)o[0];
        if (u!=this)
        {
            animator.SetBool("isShow", false);
        }
    }

    public void unShow()
    {
        animator.SetBool("isShow", false);
    }


    private void OnDestroy()
    {
        EventManager.Reomve(EventNameConfig.UI.UnShow, unShow);
    }


}